
<#import "../macro/components.ftl" as components/>
<#include "../macro/layout_default.ftl"/>

<@head>
<link rel="stylesheet" href="/misc/app/css/product_list.css"/>
<link rel="stylesheet" href="/misc/adminlte-2.3.7/plugins/daterangepicker/daterangepicker.css"/>
</@head>

<@body>
<script src="/misc/adminlte-2.3.7/plugins/daterangepicker/moment.min.js"></script>
<script src="/misc/adminlte-2.3.7/plugins/daterangepicker/daterangepicker.js"></script>
<script src="/misc/app/js/winning_list.js"></script>
</@body>

<@layout_default>
<div class="box">
    <div class="box-header with-border">
        <span class="pull-right text-muted">共 ${winningList.resultTotal} 条记录</span>
        <input type="hidden" id="resultTotal_hidden" value="${winningList.resultTotal}" />
        <input type="hidden" id="ship" value="${shipMethod!}" />
        <input type="hidden" id="scanTimeS_hidden" value="${scanTimeS!}" />
        <input type="hidden" id="scanTimeE_hidden" value="${scanTimeE!}" />
        <input type="hidden" id="cashTimeS_hidden" value="${cashTimeS!}" />
        <input type="hidden" id="cashTimeE_hidden" value="${cashTimeE!}" />
        <form class="form-inline" action="/activitywinning">
        	<input type="hidden" id="activityId_hidden" name="activityId" value="${activityId!}" />
        	<div>
            <div class="input-group">
                <div class="input-group-addon">二维码编号</div>
                <input type="text" class="form-control" style="width: 100px" name="qrcodeNum" value="${qrcodeNum!}" placeholder=""/>
            </div>
            <div class="input-group">
                <div class="input-group-addon">二维码批次</div>
                <input type="text" class="form-control" style="width: 100px" name="qrcodeName" value="${qrcodeName!}" placeholder=""/>
            </div>
            <div class="input-group">
                <div class="input-group-addon">活动商品</div>
                <input type="text" class="form-control" style="width: 100px" name="productName" value="${productName!}" placeholder=""/>
            </div>
            <div class="input-group">
                <div class="input-group-addon">奖品名称</div>
                <input type="text" class="form-control" style="width: 100px" name="prizeName" value="${prizeName!}" placeholder=""/>
            </div>
            <div class="input-group">
                <div class="input-group-addon">兑奖手机号</div>
                <input type="text" class="form-control" style="width: 120px" name="csshMobile" value="${csshMobile!}" placeholder=""/>
            </div>
            <div class="input-group">
                <div class="input-group-addon">配送方式</div>
                <select class="form-control" name="shipMethod" id="shipMethod">
                	<option value="">请选择</option>
		            <option value="1" ${(shipMethod?exists && shipMethod == 1)?string("selected","")}>自动发送</option>
		            <option value="2" ${(shipMethod?exists && shipMethod == 2)?string("selected","")}>上门自提</option>
		            <option value="3" ${(shipMethod?exists && shipMethod == 3)?string("selected","")}>物流配送</option>
		         </select>
            </div>
            </div>
            <div style="padding-top:5px;">
            	<div class="input-group">
	                <div class="input-group-addon">扫码时间</div>
	                <input type="text" class="form-control" id="winning_start" name="scanTimeS" size="18">
	            </div>
	            <div class="input-group"> 至 </div>
	            <div class="input-group">
	                <input type="text" class="form-control" id="winning_end" name="scanTimeE" size="18">
	            </div>
            	<div class="input-group">
	                <div class="input-group-addon">兑奖时间</div>
	                <input type="text" class="form-control" id="cashTime_start" name="cashTimeS" size="18">
	            </div>
	            <div class="input-group"> 至  </div>
	            <div class="input-group">
	            	<input type="text" class="form-control" id="cashTime_end" name="cashTimeE" size="18">
	            </div>

                <div class="input-group">
                    <div class="input-group-addon">红包发送</div>
                    <select class="form-control" name="redEnvelope" id="redEnvelope">
                        <option value="">全部</option>
                        <option value="0" ${(redEnvelope?exists && redEnvelope == 0)?string("selected","")}>发送失败</option>
                        <option value="2" ${(redEnvelope?exists && redEnvelope == 2)?string("selected","")}>手动发送成功</option>
                    </select>
                </div>
            </div>
	            <button type="submit" class="btn btn-warning"><i class="fa fa-search"></i> 查询</button>
	            <button type="button" id="search_reset" class="btn btn-warning"><i class="fa"></i> 重置</button>
            </div>
            
        </form>
        <form class="form-inline hide">
            <input class="form-control"/>
            <input type="email" class="form-control"/>
            <button type="submit" class="btn btn-default">Send invitation</button>
        </form>
    </div>

    <!-- /.box-header -->
    <div class="box-body">
        <table class="table table-striped table-hover">
            <tr>
                <th>ID</th>
                <th>二维码编号</th>
                <th>类型</th>
                <th>二维码批次</th>
                <th>活动商品</th>
                <th>扫码时间</th>
                <th>奖品名称</th>
                <th>奖品价格</th>
                <th>配送方式</th>
                <th>兑奖手机号</th>
                <th>收货人手机号</th>
                <th>红包发送</th>
                <th>兑奖时间</th>
                <th>操作</th>
            </tr>
            <#list winningList.result as item>
                <tr>
                    <td>${item.id}</td>
                    <td><#if item.qrcodeId?exists>${item.qrcodeId}</#if></td>
                     <td><#if item.qrcodeType?exists><#if item.qrcodeType==4><span class="text-green">组合码瓶码</span>
                    	<#elseif item.qrcodeType==5><span class="text-green">组合码箱码</span><#elseif item.qrcodeType==2||item.qrcodeType==6||item.qrcodeType==7>
                    	<span class="text-green">普通码瓶码</span><#elseif item.qrcodeType==3><span class="text-green">普通码箱码</span></#if></#if>
                    </td>
                    <td><#if item.qrcodeName?exists>${item.qrcodeName}</#if></td>
                    
                    <td><#if item.productName?exists>${item.productName}</#if></td>
                    <td><#if item.scanTime?exists>${item.scanTime?number_to_datetime}</#if></td>
                    <td><#if item.prizeName?exists>${item.prizeName!}</#if></td>
                    <td><#if item.prizePrice?exists>${item.prizePrice?string("0.00")}</#if></td>
                    <td><#if item.shipMethod?exists><#if item.shipMethod=='1'><span class="text-green">自动发送</span><#elseif item.shipMethod=='2'><span class="text-yellow">上门自提</span><#else><span class="text-danger">物流配送</span></#if></#if></td>
                    <td><#if item.csshMobile?exists>${item.csshMobile?c}</#if></td>
                    <td><#if item.mobile?exists>${item.mobile?c}</#if></td>
                    <td>
                        <#if item.redEnvIsSuc?exists>
                            <#if item.redEnvIsSuc==1>
                                <span class="text-green">发送成功</span>
                            <#elseif item.redEnvIsSuc==2>
                                <span class="text-yellow">手动发送成功</span>
                            <#elseif item.redEnvIsSuc==0>
                                <span class="text-yellow">发送失败</span>
                            <#elseif item.redEnvIsSuc==3>
                            <span class="text-yellow">发送中</span>
                            </#if>
                        </#if>
                    </td>
                    <td><#if item.cashTime?exists&&item.redEnvIsSuc?exists&&(item.redEnvIsSuc==1 || item.redEnvIsSuc==2)>${item.cashTime?number_to_datetime}</#if></td>
                    <td id="operation">
                        <button type="button" class="btn btn-default btn-xs" name="btn_detail_winning" data-winning-id="${item.id?c}">详情</button>
                        <#if item.shipMethod?exists><#if item.shipMethod=='3'>
                        	<#if item.haveDeliveryInfo ==0>
                        		<button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#md_edit_delivery" data-prizeId="${item.prizeId!0}" data-winning-id="${item.id?c}">配送</button>
                    		<#else><span class="text-green" style="font-size:12px;">已配送</span>
                    		</#if>
                    	</#if></#if>
                        <#if item.redEnvIsSuc?exists>
                            <#if item.redEnvIsSuc==0>
                                <button type="button" class="btn btn-default btn-xs" name="send_evn" id="send_evn"  data-winningid="${item.id?c}"  data-prizeid="${item.prizeId!0}">发送</button>
                            <#elseif item.redEnvIsSuc==2>
                            <span class="text-green" style="font-size:12px;">已发送<span>
                            <#elseif item.redEnvIsSuc==3>
                            <span class="text-green" style="font-size:12px;">发送中<span>
                            </#if>
                        </#if>
                    </td>
                </tr>
            </#list>
        </table>
        <table class="table table-striped table-hover">
        	<tr>
        		<td colspan="13" style="text-align:right;background-color:white;">
        			<a href="javascript:void(0);" name="btn_export"><i class="glyphicon glyphicon-save"></i> 数据导出</a>
                    <a href="javascript:void(0);" name="btn_send_evn_false" id="btn_send_evn_false"><i class="glyphicon glyphicon-save"></i> 红包补发数据</a>
        		</td>
        	</tr>
        </table>
    </div>
    <!-- /.box-body -->
    <div class="box-footer text-center">
        <@components.pagination "/activitywinning?activityId=${activityId!}&qrcodeNum=${qrcodeNum!}&qrcodeName=${qrcodeName!}&productName=${productName!}
        &prizeName=${prizeName!}&mobile=${mobile!}&shipMethod=${shipMethod!}&scanTimeS=${scanTimeS!}&scanTimeE=${scanTimeE!}&cashTimeS=${cashTimeS!}&cashTimeE=${cashTimeE!}
        &redEnvelope=${redEnvelope!}&page=$page",winningList.page,winningList.pageTotal/>
    </div>
</div>

<!--===========================Modal 物流配送信息 start  ======================---->
<div class="modal" id="md_edit_delivery" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"><i class="fa fa-pencil-square-o"></i> 配送信息</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_edit_delivery">
                    <input type="hidden" id="_pzid" name="pzid" />
                     <input type="hidden" id="_wind" name="wind" />
                    <div class="form-group">
                        <label class="col-sm-2 control-label">收件人：</label>
                        <div class="col-sm-10" style="padding-top:7px;">
                            <span name="consignee" id="consignee"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">联系电话：</label>
                        <div class="col-sm-10" style="padding-top:7px;">
                            <span name="mobile" id="mobile"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">配送地址：</label>
                        <div class="col-sm-10" style="padding-top:7px;">
                            <span name="adress" id="adress"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 承运方</label>
                        <div class="col-sm-10">
                            <select class="form-control" id="logisticsCompany" name="logisticsCompanyId">
                                <option value="">请选择承运方</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold"></strong>承运方官网：</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="website" name="website"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong>运单号：</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="waybillNumber" id="waybillNumber"/>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_edit_delivery">保存</button>
            </div>
        </div>
    </div>
</div>
<!--===========================Modal 物流配送信息 end  ======================---->
</@layout_default>